home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Hardware / BetaScan / BetaScanDev / Include / scanner.h < prev   
C/C++ Source or Header  |  1999-01-23  |  7KB  |  215 lines

  1. //
  2. //                        Scanner include
  3. //
  4. //                            StormC
  5. //
  6. //                        version 98.12.31
  7. //
  8. #ifndef SCANNER_H
  9. #define SCANNER_H
  10.  
  11. #include <exec/types.h>
  12. #include <exec/io.h>
  13.  
  14. // Non standard command for a scanner device driver
  15. #define SCANCMD_CONTROL CMD_NONSTD
  16.  
  17. // Status codes
  18. #define SCAN_STATUS_OK           0
  19. #define SCAN_STATUS_EOF          1
  20.  
  21. // Open error codes
  22. #define SCAN_OPNERR_DEVICE       5
  23. #define SCAN_OPNERR_NOT_SCANNER  6
  24. #define SCAN_OPNERR_UNKNOWN      7
  25. #define SCAN_OPNERR_MEMORY       8
  26. #define SCAN_OPNERR_FATAL        9
  27.  
  28. #define SCAN_ERR_NOTSCANNING    10
  29. #define SCAN_ERR_not_used       11
  30. #define SCAN_ERR_MEMORY         12
  31. #define SCAN_ERR_READY          13
  32. #define SCAN_ERR_PARAMETER      14
  33. #define SCAN_ERR_HARDWARE       15
  34. #define SCAN_ERR_COMMUNICATION  16
  35. #define SCAN_ERR_MISC           17
  36.  
  37.  
  38. typedef int fixed;
  39.  
  40. /* double <-> fixed point conversion */
  41. #define DOUBLE_FIX(v) ((int)   ((v)*(1 << 16)))
  42. #define FIX_DOUBLE(v) (((double)(v)/(double)(1 << 16)))
  43. #define FIX_INT(v) ((v)>>16)
  44. #define INT_FIX(v) ((v)<<16)
  45.  
  46. typedef enum
  47. {
  48.   ID_NONE = 0,
  49.   ID_SCANMODE,
  50.   ID_TL_X,             /* upper left corner of scan area     */
  51.   ID_TL_Y,             /* upper left corner of scan area     */
  52.   ID_BR_X,             /* bottom right corner of scan area   */
  53.   ID_BR_Y,             /* bottom right corner of scan area   */
  54.   ID_RESOLUTION,       /* scan resolution (combined x and y) */
  55.   ID_HALFTONEPATTERN,
  56.   ID_BRIGHTNESS,
  57.   ID_CONTRAST,
  58.   ID_ANALOGGAMMA,
  59.   ID_BLACKLEVEL,       /* some times called shadow           */
  60.   ID_WHITELEVEL,       /* some times called highlight        */
  61.   ID_THRESHOLD,
  62.   ID_EXPOSURETIME,
  63.   ID_ADF,
  64.   ID_SPEED,
  65.   ID_NUMBER_OF_OPTIONS
  66. } OptionId;
  67.  
  68. typedef enum
  69. {
  70.   TYPE_BOOL = 0,
  71.   TYPE_INT,
  72.   TYPE_FIXED,    /* Fixed point number - use DOUBLE_FIX and  */
  73.                  /* FIX_DOUBLE macros to convert to double   */
  74.   TYPE_STRING
  75. } ValueType;
  76.  
  77. typedef enum
  78. {
  79.   UNIT_NONE = 0,         /* the value is unit-less (e.g., # of scans) */
  80.   UNIT_PIXEL,            /* don't use!                                */
  81.   UNIT_BIT,              /* value is number of bits                   */
  82.   UNIT_MM,               /* value is millimeters                      */
  83.   UNIT_DPI,              /* value is dots per inch                    */
  84.   UNIT_PERCENT,          /* value is a percentage                     */
  85.   UNIT_MICROSECOND       /* value is micro seconds                    */
  86. } ValueUnit;
  87.  
  88. typedef enum
  89. {
  90.   CONSTRAINT_NONE = 0,
  91.   CONSTRAINT_RANGE,
  92.   CONSTRAINT_WORD_LIST,
  93.   CONSTRAINT_STRING_LIST
  94. } Constraint;
  95.  
  96.  
  97. typedef struct
  98. {
  99.   int min;
  100.   int max;
  101.   int quant;
  102. }
  103. Range;
  104.  
  105. struct OptionDescriptor
  106. {
  107.   OptionId   od_optionID;
  108.   ValueType  od_valueType;
  109.   ValueUnit  od_valueUnit;
  110.   Constraint od_constraintType;
  111.   union
  112.   {
  113.     char** stringList;  /* Null terminated array of string values  */
  114.     int*   numberList;  /* Legal values - numberList[0] = number   */
  115.     Range* numberRange;
  116.   }
  117.   od_constraint;
  118.   void* od_specialInfo; /* See below                               */
  119. };
  120.  
  121. //
  122. // If non zero, special info has a content depending of option id
  123. //
  124. //  ID_SCANMODE:        If constraint type is a list specialInfo is
  125. //                      a pointer to an int list of scan depth values
  126. //
  127. //  ID_HALFTONEPATTERN: A pointer to an int list of boolean values
  128. //                      telling if the pattern works for the
  129. //                      corresponding scan mode
  130. //
  131. //  ID_BRIGHTNESS:      If ValueType is not UNIT_PERCENT and 
  132. //  ID_CONTRAST:        constraint type is a list specialInfo is
  133. //                      a pointer to an int list of percentage
  134. //                      values corresponding to each value in the
  135. //                      constraint list.
  136. //
  137. struct ScannerOptions
  138. {
  139.   char   so_scannerVendor[40];
  140.   char   so_scannerModel[40];
  141.  
  142.   UBYTE  so_driverVersion;
  143.   UBYTE  so_driverRevision;
  144.  
  145.   double so_docWidth;                      /* Paper size in mm             */
  146.   double so_docHeight;
  147.  
  148.   UWORD  so_flags;                         /* Not used                     */
  149.   UWORD  so_optionNum;                     /* Number of option descriptors */
  150.  
  151.   struct OptionDescriptor* so_descriptor;
  152. };
  153.  
  154. //
  155. // Structure to be used by controlOption routine
  156. //
  157. struct OptionValue
  158. {
  159.   OptionId sp_optionID;
  160.   int      sp_value;
  161.   ULONG    sp_flags;
  162. };
  163.  
  164. // optionValue flags
  165. //
  166. #define CONTROL_SET        (1<<0)      /* Set new value              */ 
  167. #define CONTROL_GET        (1<<1)      /* Return current value       */
  168.                                        /* If both bits are set then  */
  169.                                        /* SET is exec. before GET    */
  170.  
  171. #define CONTROL_ROUNDED    (1<<16)     /* Value set is not exact     */
  172. #define CONTROL_RANGE      (1<<17)     /* Out of range - not set     */
  173. #define CONTROL_DISABLED   (1<<18)     /* Option disabled - not set  */
  174. #define CONTROL_INVALID    (1<<19)     /* Option not supported       */
  175.  
  176. #define CONTROL_CALLMASK   0x0000FFFF
  177. #define CONTROL_RETURNMASK 0xFFFF0000
  178.  
  179.  
  180. typedef enum
  181. {
  182.   FORMAT_BW = 0,
  183.   FORMAT_GRAY,                /* 8 bit gray scale                    */
  184.   FORMAT_RED,
  185.   FORMAT_GREEN,
  186.   FORMAT_BLUE,
  187.   FORMAT_RGB,                 /* Each pixel as 3 (24bit) byte RGB    */
  188.   FORMAT_RGB_RANDOM           /* Colors separated in 8 bit red,      */
  189. } LineFormat;                 /* green and blue components ariving   */
  190.                               /* (posibly) in random order. Used by  */
  191.                               /* 3 pass scanners.                    */
  192.  
  193. struct ScanInformation
  194. {
  195.   double     sv_xResolution;  /* actual horizontal resolution        */
  196.   double     sv_yResolution;  /* actual vertical resolution          */
  197.   LineFormat sv_lineFormat;   /* format of scan lines                */
  198.   UWORD      sv_imageWidth;   /* image width in pixels               */
  199.   UWORD      sv_imageHeight;  /* image height in pixels              */
  200.   UWORD      sv_imageDepth;   /* image depth in bits                 */
  201.   UWORD      sv_bytesPerLine; /* bytes per line read                 */
  202.   ULONG      sv_Flags;        /* data information flags              */
  203. };
  204.  
  205. struct ScanLine
  206. {
  207.   UBYTE*     sl_data;
  208.   LineFormat sl_color;   /* If sv_lineFormat is FORMAT_RGB_RANDOM    */
  209. };                       /* this is either FORMAT_RED, FORMAT_GREEN  */
  210.                          /* or FORMAT_BLUE. Otherwise it must be the */
  211.                          /* same as sv_lineFormat.                   */
  212.  
  213.  
  214. #endif /* SCANNER_H */
  215.